package com.rbs.servlet;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
import cn.hutool.captcha.LineCaptcha;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebServlet("/checkServlet")
public class CheckServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        LineCaptcha captcha= CaptchaUtil.createLineCaptcha(150,50);
        String code = captcha.getCode();
        HttpSession session = req.getSession();
        session.setAttribute("code",code);
        ServletOutputStream outputStream = resp.getOutputStream();
        captcha.write(outputStream);
    }
}
